package com.ldxx.mustwinlottery.app;

import android.app.Application;
import android.content.Context;

import com.ldxx.mustwinlottery.R;

import io.realm.DynamicRealm;
import io.realm.Realm;
import io.realm.RealmConfiguration;
import io.realm.RealmMigration;

/**
 * 自定义Application对象
 * Created by ldxx
 * on 16/8/26.
 */

public class LotteryApplication extends Application {
    private static Context context;
    private static Realm realm;

    @Override
    public void onCreate() {
        super.onCreate();
        context = this;
    }

    public static String getBaseUrl() {
        return context.getResources().getString(R.string.BASE_HOST);
    }

    public static Context getContext() {
        return context;
    }

    public static Realm getRealm() {
        RealmConfiguration config = new RealmConfiguration.Builder(context)
                .schemaVersion(1)
                .name("lottery.realm")
                .migration(new Migration())
                .build();
        return Realm.getInstance(config);
    }
}
